Imports SchemaCodeGen

Partial Public Class pages_Contents_usercontrols_UCContent : Inherits UserControl

#Region "Members"
	Private m_setId As Integer
	Private m_templateId As Integer
	Private m_isTemplatePage As Boolean
#End Region


#Region "Interfaces"
	'Search page
	Public Sub Display(ByVal c As CContent, ByVal number As Integer)
		If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

		m_setId = c.ContentSetId
		m_templateId = c.ContentTemplateId

		litNum.Text = number.ToString()
		Display(c)
	End Sub
	'TemplateSet-orientated, for Template page
	Public Sub Display(ByVal templateSet As CTemplateSet, ByVal templateId As Integer, ByVal c As CContent, ByVal number As Integer)
		If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

		m_setId = templateSet.SetId
		m_templateId = templateId
		m_isTemplatePage = True

		colTemplate.Visible = False

		litNum.Text = number.ToString()


		If Not IsNothing(c) Then
			Display(c)
		Else
			colDate1.Visible = False
			colDate2.Visible = False
			colHash.Visible = False
			colLength.Visible = False
		End If
	End Sub
	'Template-orientated, for TemplateSet page
	Public Sub Display(ByVal template As CTemplate, ByVal setId As Integer, ByVal c As CContent, ByVal number As Integer)
		If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

		m_setId = setId
		m_templateId = template.TemplateId
		m_isTemplatePage = False

		colPattern.Visible = False

		litNum.Text = number.ToString()

		If Not IsNothing(c) Then
			Display(c)
		Else
			colDate1.Visible = False
			colDate2.Visible = False
			colHash.Visible = False
			colLength.Visible = False
		End If
	End Sub

	'Private
	Private Sub Display(c As CContent)
		lnkTemplate.Text = c.Template.TemplateName
		lnkTemplate.NavigateUrl = CSitemap.Template(c.ContentTemplateId)

		lnkPattern.Text = c.TemplateSet.SetName_
		lnkPattern.NavigateUrl = CSitemap.TemplateSetEdit(c.ContentSetId)

		lblLength.Text = CUtilities.FileSize(c.ContentText.Length)
		lblLength.ToolTip = c.ContentText.Length.ToString("n0")

		lnkHash.Text = CBinary.ToBase64(c.ContentMD5, 8)
		lnkHash.NavigateUrl = CSitemap.ContentEdit(c.ContentSetId, c.ContentTemplateId)

		lblDateCreated.Text = CUtilities.Timespan(c.ContentCreated)
		lblDateCreated.ToolTip = CUtilities.LongDateTime(c.ContentCreated)
		lblModified.Text = CUtilities.Timespan(c.ContentModified)
		lblModified.ToolTip = CUtilities.LongDateTime(c.ContentModified)
	End Sub
#End Region


End Class